/*******************************************************************************
 * Homework 6 'ComparisonStart' class implemation file
 * Author: Andrew Shore, Wes Ring, JC Anderson, Colin Edwards
 * Date Last Modified: 5 April 2010
 *
 * This is simply a class to implement a comparison of 'Process' instances. In
 * this case all we do is compare the start time to sort the queue using 
 * 'startTime'. Used as the comparison class for the pending queue.
 *
*******************************************************************************/

#include "ComparisonStart.h"

/*******************************************************************************
 * Constructor.
 ******************************************************************************/
ComparisonStart::ComparisonStart(){

}

/*******************************************************************************
 * Overloaded comparison operator () to compare two Process objects based on
 * start time
 * Author: Andrew Shore, Wes Ring, JC Anderson, Colin Edwards
 * Date Last Modified: 5 April 2010
 *
 * This overloaded operator is used to compare two process objects to determine
 * where they are are placed in the pending queue. The pending queue is 
 * sorted based on startTime and finishTime is used as a tiebreaker. The
 * pending queue uses a min heap as opposed to a max heap so the startTime
 * of elements increase as one moves further down the tree.
 *
 * Parameters: 
 * const Process& procOne - first proceess to be compared, const because we
 *                          don't want to change its value, passed by reference
 * const Process& procTwo - second process to be compared
 *
 * Output: none
 *
 * Returns: True if procOne has a greater start time to procTwo,
 * False if procTwo has a greater start time. If the start times are equal
 * than the function returns true if procOne as a greater finish time than
 * procTwo, and false if procTwo has the greater finish time.
 *
 *****************************************************************************/
bool ComparisonStart::operator() 
   (const Process& procOne, const Process& procTwo) const{

  if(procOne.getStartTime() > procTwo.getStartTime() ){
    return true;
  }else if( procOne.getStartTime() < procTwo.getStartTime() ){
    return false;
  }else{
    return (procOne.getFinishTime() > procTwo.getFinishTime());
  }


}
